<html>
<head>
<script type="text/javascript" src="../js/jquery-1.4.2.min.js"></script>
<script type="text/javascript">
	$(document).ready(
			function() {
				$("button").click(
						function() {

							//$.getJSON("test.json", function(data){
							$.getJSON("service.jsp", function(data) {

								/******************
								alert('Success. Result: name => ' + data.name + ',' + 'balance => ' + data.balance);
								$("div").html('Success. Result: name => ' + data.name + ',' + 'balance => ' + data.balance);
								$("#mytable").append('<tr><td>' + data.name + '</td><td>' + data.balance + '</td></tr>');
								/******************/
								$.each(data.jsonChildarray, function(i, data) {
									$("#mytable").append(
											'<tr><td>' + data.B + '</td><td>'
													+ i + '</td></tr>');
								});
								/******************/
							});

						});

				
				
				
				$("#DROPID").change(
					function() {
					alert('Handler for .change() called.');
				});
				
				$('#jsonForm').ajaxForm({
					// dataType identifies the expected content type of the server response 
					dataType : 'json',

					// success identifies the function to invoke when the server response 
					// has been received 
					success : processJson
				});

				
			});

			function processJson(data) { 
			    // 'data' is the json object returned from the server 
			    alert(data.message); 
			}
</script>

</head>
<body>
	<input id="DROPID" type="text" name="fname" />
	<form id='myform' >
		<table id="mytable">
			<tr>
				<th>序號</th>
				<th>儲位</th>
				<th>品名</th>
				<th>商品代碼</th>
				<th>UPC</th>
				<th>效期</th>
				<th>箱入數</th>
				<th>庫存數</th>
				<th>初盤數量</th>
			</tr>
		</table>
	</form>
	<div>
		<h2>Let AJAX change this text</h2>
	</div>
	<button>Change Content</button>


<p />
<p />
	<form id="jsonForm" action="json-echo.jsp" method="post">
		Message: <input type="text" name="message" value="JSONmessage" /> 
		<br />
		<input type="text" name="lname" disabled="disabled" value="haha"/>
		<br />
		<input type="submit" value="Echo as JSON" />
	</form>

</body>
</html>

